<!-- 随访用户 -->
<template>
	<globalModal
		:title="`${doctor.realName}的随访记录`"
		:width="1200"
		:visible="visible"
		:footer="null"
		@cancel="handleCancel"
	>
		<!-- 查询区域 -->
		<!-- <a-form layout="inline">
			<a-form-item label="昵称">
				<a-input v-model="filter.nickName" style="width: 200px" placeholder="请输入昵称" />
			</a-form-item>
			<a-form-item label="联系方式"
				><a-input v-model="filter.phone" style="width: 200px" placeholder="请输入联系方式"
			/></a-form-item>
			<a-space class="table-page-search-submitButtons">
				<a-button type="primary" @click="searchQuery"> 搜索 </a-button>
				<a-button class="ant-btn-yellow" @click="searchReset">清除</a-button>
			</a-space>
		</a-form> -->
		<a-tabs :default-active-key="tabIndex" @change="tabChange">
			<a-tab-pane key="1" tab="高血压"> </a-tab-pane>
			<a-tab-pane key="2" tab="糖尿病"> </a-tab-pane>
			<!-- <a-tab-pane key="3" tab="体重体脂"> </a-tab-pane> -->
		</a-tabs>
		<s-table
			bordered
			:columns="columns"
			:data="loadListData"
			rowKey="domesticAnimalsId"
			ref="table"
			:scroll="{ x: 1145, y: 260 }"
			size="small"
			:isFirstLoad="false"
			:showPagination="true"
		>
			<span slot="result" slot-scope="text, record">
				{{ record.testNutritionalTime == '随机' ? '' : record.result }}
			</span>
			<span slot="testNutritionalTime" slot-scope="text, record">
				{{ record.testNutritionalTime == '随机' ? record.result : '' }}
			</span>
		</s-table>
	</globalModal>
</template>

<script>
import { sysManageapi, doctorManageapi } from '@/api/index.js';
import { ModalMixins } from '@/mixins';
const columns = {
	columns1: [
		{
			title: '随访时间',
			dataIndex: 'createTime',
			key: 'createTime',
			ellipsis: true,
		},
		{
			title: '收缩压',
			dataIndex: 'systolic_pressure',
			key: 'systolic_pressure',
			ellipsis: true,
		},
		{
			title: '舒张压',
			dataIndex: 'diastolic_pressure',
			key: 'diastolic_pressure',
			ellipsis: true,
		},
		{
			title: '随访分类',
			dataIndex: 'sfType',
			key: 'sfType',
			ellipsis: true,
		},
		{
			title: '随访方式',
			dataIndex: 'sfWay',
			key: 'sfWay',
			ellipsis: true,
		},
		{
			title: '测量医生',
			dataIndex: 'oprDocterName',
			key: 'oprDocterName',
			ellipsis: true,
		},
	],
	columns2: [
		{
			title: '随访时间',
			dataIndex: 'createTime',
			key: 'createTime',
			ellipsis: true,
		},
		{
			title: '空腹血糖',
			dataIndex: 'result',
			key: 'result',
			scopedSlots: {
				customRender: 'result',
			},
			ellipsis: true,
		},
		{
			title: '非空腹血糖',
			dataIndex: 'testNutritionalTime',
			key: 'testNutritionalTime',
			ellipsis: true,
			scopedSlots: {
				customRender: 'testNutritionalTime',
			},
		},
		{
			title: '随访分类',
			dataIndex: 'sfType',
			key: 'sfType',
			ellipsis: true,
		},
		{
			title: '随访方式',
			dataIndex: 'sfWay',
			key: 'sfWay',
			ellipsis: true,
		},
		{
			title: '测量医生',
			dataIndex: 'oprDocterName',
			key: 'oprDocterName',
			ellipsis: true,
		},
	],
	columns3: [
		{
			title: '随访时间',
			dataIndex: 'phone1',
			key: 'phone1',
			ellipsis: true,
		},
		{
			title: '心电',
			dataIndex: 'phone2',
			key: 'phone2',
			ellipsis: true,
		},
		{
			title: '体重体脂',
			dataIndex: 'phone3',
			key: 'phone3',
			ellipsis: true,
		},
		{
			title: '血氧饱和度',
			dataIndex: 'phone4',
			key: 'phone4',
			ellipsis: true,
		},
		{
			title: '随访分类',
			dataIndex: 'phone5',
			key: 'phone5',
			ellipsis: true,
		},
		{
			title: '随访方式',
			dataIndex: 'phone6',
			key: 'phone6',
			ellipsis: true,
		},
		{
			title: '测量医生',
			dataIndex: 'phone7',
			key: 'phone7',
			ellipsis: true,
		},
	],
};
export default {
	name: 'hisRecord',
	mixins: [ModalMixins],
	data() {
		return {
			columns: columns.columns1,
			visible: false,
			doctorId: '',
			doctor: {},
			filter: {},
			tabIndex: '1',
		};
	},
	created() {},
	methods: {
		show(doctor) {
			console.log('每行数据', JSON.stringify(doctor));
			this.columns = columns.columns1;
			this.doctorId = doctor.doctorId;
			this.doctor = doctor;
			this.visible = true;
			this.$nextTick(() => {
				this.$refs.table.refresh();
			});
		},
		searchQuery() {
			this.$refs.table.refresh();
		},
		searchReset() {
			this.filter = {};
			this.$refs.table.refresh();
		},
		handleCancel() {
			this.$emit('close');
			this.tabIndex = '1';
			this.visible = false;
		},
		loadListData(parameter) {
			let params = Object.assign(
				{},
				{
					patientId: this.doctor.patientId,
				},
				{
					pageNum: parameter.pageNum,
					pageSize: parameter.pageSize,
				}
			);
			let url = doctorManageapi.doctorUrl.getdocBP2AList;
			if (this.tabIndex == '1') {
				url = doctorManageapi.doctorUrl.getdocBP2AList;
			} else {
				url = doctorManageapi.doctorUrl.gedocBoList;
			}
			return this.$postAction(url, params).then((res) => {
				this.list = res.data;
				return res.data;
			});
		},
		add() {
			this.$refs.addModal.show(this.doctorId);
		},
		tabChange(value) {
			this.tabIndex = value;
			console.log(value);
			this.columns = columns['columns' + value];
			this.$refs.table.refresh();
		},
	},
};
</script>

<style lang="less" scoped>
/deep/.table-page-search-submitButtons {
	margin-top: 4px;

	.ant-btn-blue {
		color: #fff;
		background-color: #3b74f8;
		border-color: #3b74f8;
	}

	.ant-btn-yellow {
		color: #fff;
		background-color: rgb(248, 191, 59);
		border-color: rgb(248, 191, 59);
	}
}

/deep/ .table-wrapper .operation {
	line-height: 1;

	a {
		&.del {
			color: #d43030;
		}

		&.edit {
			color: #0a8783;
		}
	}

	a + a {
		margin-left: 12px;
	}
}

/deep/.ant-form {
	.ant-form-item {
		margin-bottom: 0;
	}
}
</style>
